home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_06_07
/
v6n7065b.txt
< prev
next >
Wrap
Text File
|
1989-09-26
|
2KB
|
59 lines
/**************************** Listing 2 ****************************/
/******* *******/
/******* Delete all of the current actions in the grammar *******/
/******* rules section of yref2.y. All have the general *******/
/******* form: { printf(......) }. Then add the actions *******/
/******* as shown below (from { to }, inclusive). Note *******/
/******* that there are no changes to the grammar rules, *******/
/******* which are only repeated for setting the context. *******/
/******* *******/
/*********************************************************************/
direct_declarator:
IDENTIFIER
{ yn_decl = 1; root = addtree(root, $1); }
| '(' declarator ')'
| direct_declarator '[' ']' %prec '*'
| direct_declarator '[' constant ']' %prec '*' /* Variant */
| direct_declarator '(' parameter_type_list ')' %prec '*'
| direct_declarator '(' ')' %prec '*'
| direct_declarator '(' identifier_list ')' %prec '*'
;
identifier_list:
IDENTIFIER
{ yn_decl = 0; root = addtree(root, $1); }
| identifier_list ',' IDENTIFIER
{ yn_decl = 0; root = addtree(root, $3); }
;
statement:
compound_statement
| expression ';'
| KEYWORD '(' expression ')' statement
| KEYWORD for_construct statement
| KEYWORD statement
| KEYWORD constant ':' statement
| KEYWORD ':' statement
| KEYWORD IDENTIFIER ';'
{ yn_decl = 0; root = addtree(root, $2); }
| IDENTIFIER ':' statement
{ yn_decl = 0; root = addtree(root, $1); }
| ';'
;
primary_expression:
IDENTIFIER
{ yn_decl = 0; root = addtree(root, $1); }
| constant
| STRING
| '(' expression ')'
| primary_expression '(' ')'
| primary_expression '(' expression ')'
| primary_expression '[' expression ']'
| primary_expression '.' IDENTIFIER
{ yn_decl = 0; root = addtree(root, $3); }
;